{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3c529047",
   "metadata": {},
   "source": [
    "# #python 基础\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "631507f5",
   "metadata": {},
   "source": [
    "##本周学习内容\n",
    "  1.pycharm安装和jupyter notebook的安装学习 \n",
    "  2.主要学习了jupyter notebook的使用 \n",
    "  3.注册github 领取学生礼包 "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "90b2cd2d",
   "metadata": {},
   "source": [
    "·官网：http://juyter.org/ ,里面有jupyter notebook的具体介绍 \n",
    "·利用终端打开jupyter notebook \n",
    "·jupyter notebook 可以做代码的系统管理，学会整理每周的学习内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b9e604d2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "holle world\n"
     ]
    }
   ],
   "source": [
    "print(\"holle world\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3de7157",
   "metadata": {},
   "source": [
    "## 1.认识标准库\n",
    "###函数+模块=标准库\n",
    "####1.python模块类型：标准库、开源模块、自定义模块\n",
    "####2.观察标准库\n",
    "import sys\n",
    "sys.platform"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3809926c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.8.8 (default, Apr 13 2021, 12:59:45) \n",
      "[Clang 10.0.0 ]\n"
     ]
    }
   ],
   "source": [
    "print(sys.version)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8dbe8bf7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/Users/wenqy1022'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0a2828ae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "environ{'TERM_SESSION_ID': 'C7BE23D3-8F1E-4B80-9442-22C040EB1473',\n",
       "        'CONDA_ROOT': '/opt/anaconda3',\n",
       "        'TMPDIR': '/var/folders/mr/gshzl4sn75l_l0fb_9_zfpf80000gn/T/',\n",
       "        'XPC_FLAGS': '0x0',\n",
       "        'TERM': 'xterm-color',\n",
       "        'LANG': 'zh_CN.UTF-8',\n",
       "        'SSH_AUTH_SOCK': '/private/tmp/com.apple.launchd.RloJ5YAIm6/Listeners',\n",
       "        'XPC_SERVICE_NAME': '0',\n",
       "        'TERM_PROGRAM': 'Apple_Terminal',\n",
       "        'TERM_PROGRAM_VERSION': '433',\n",
       "        'QT_API': 'pyqt5',\n",
       "        'SHLVL': '2',\n",
       "        'PWD': '/Users/wenqy1022',\n",
       "        'SHELL': '/bin/zsh',\n",
       "        'HOME': '/Users/wenqy1022',\n",
       "        'LOGNAME': 'wenqy1022',\n",
       "        'USER': 'wenqy1022',\n",
       "        'PATH': '/opt/anaconda3/bin:/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',\n",
       "        'OLDPWD': '/Users/wenqy1022',\n",
       "        'CONDA_EXE': '/opt/anaconda3/bin/conda',\n",
       "        '_CE_M': '',\n",
       "        '_CE_CONDA': '',\n",
       "        'CONDA_PYTHON_EXE': '/opt/anaconda3/bin/python',\n",
       "        'CONDA_SHLVL': '1',\n",
       "        'CONDA_PREFIX': '/opt/anaconda3',\n",
       "        'CONDA_DEFAULT_ENV': 'base',\n",
       "        'CONDA_PROMPT_MODIFIER': '(base) ',\n",
       "        'LC_CTYPE': 'UTF-8',\n",
       "        '_': '/opt/anaconda3/bin/jupyter',\n",
       "        'JPY_PARENT_PID': '2654',\n",
       "        'CLICOLOR': '1',\n",
       "        'PAGER': 'cat',\n",
       "        'GIT_PAGER': 'cat',\n",
       "        'MPLBACKEND': 'module://ipykernel.pylab.backend_inline'}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.environ"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ca54166a",
   "metadata": {},
   "source": [
    "##datetime里有年月日时分秒毫秒"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "47ce48ab",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "64c3e776",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2021, 9, 9)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a62bc60b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e43a9cae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "a48a6067",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().month"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "73a579b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2021"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().year"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "4861453e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-09-09'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.isoformat(datetime.date.today())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "d71145dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "885027c3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'22:08'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strftime(\"%H:%M\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e6962602",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "bced6b37",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'09:09'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strftime(\"%m:%d\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "7ef81bf6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Thursday:p'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strftime(\"%A:p\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "63031030",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "30116215",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1631196866.431527"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "41e0c7af",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in module time:\n",
      "\n",
      "NAME\n",
      "    time - This module provides various functions to manipulate time values.\n",
      "\n",
      "DESCRIPTION\n",
      "    There are two standard representations of time.  One is the number\n",
      "    of seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer\n",
      "    or a floating point number (to represent fractions of seconds).\n",
      "    The Epoch is system-defined; on Unix, it is generally January 1st, 1970.\n",
      "    The actual value can be retrieved by calling gmtime(0).\n",
      "    \n",
      "    The other representation is a tuple of 9 integers giving local time.\n",
      "    The tuple items are:\n",
      "      year (including century, e.g. 1998)\n",
      "      month (1-12)\n",
      "      day (1-31)\n",
      "      hours (0-23)\n",
      "      minutes (0-59)\n",
      "      seconds (0-59)\n",
      "      weekday (0-6, Monday is 0)\n",
      "      Julian day (day in the year, 1-366)\n",
      "      DST (Daylight Savings Time) flag (-1, 0 or 1)\n",
      "    If the DST flag is 0, the time is given in the regular time zone;\n",
      "    if it is 1, the time is given in the DST time zone;\n",
      "    if it is -1, mktime() should guess based on the date and time.\n",
      "\n",
      "CLASSES\n",
      "    builtins.tuple(builtins.object)\n",
      "        struct_time\n",
      "    \n",
      "    class struct_time(builtins.tuple)\n",
      "     |  struct_time(iterable=(), /)\n",
      "     |  \n",
      "     |  The time value as returned by gmtime(), localtime(), and strptime(), and\n",
      "     |  accepted by asctime(), mktime() and strftime().  May be considered as a\n",
      "     |  sequence of 9 integers.\n",
      "     |  \n",
      "     |  Note that several fields' values are not the same as those defined by\n",
      "     |  the C language standard for struct tm.  For example, the value of the\n",
      "     |  field tm_year is the actual year, not year - 1900.  See individual\n",
      "     |  fields' descriptions for details.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      struct_time\n",
      "     |      builtins.tuple\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  tm_gmtoff\n",
      "     |      offset from UTC in seconds\n",
      "     |  \n",
      "     |  tm_hour\n",
      "     |      hours, range [0, 23]\n",
      "     |  \n",
      "     |  tm_isdst\n",
      "     |      1 if summer time is in effect, 0 if not, and -1 if unknown\n",
      "     |  \n",
      "     |  tm_mday\n",
      "     |      day of month, range [1, 31]\n",
      "     |  \n",
      "     |  tm_min\n",
      "     |      minutes, range [0, 59]\n",
      "     |  \n",
      "     |  tm_mon\n",
      "     |      month of year, range [1, 12]\n",
      "     |  \n",
      "     |  tm_sec\n",
      "     |      seconds, range [0, 61])\n",
      "     |  \n",
      "     |  tm_wday\n",
      "     |      day of week, range [0, 6], Monday is 0\n",
      "     |  \n",
      "     |  tm_yday\n",
      "     |      day of year, range [1, 366]\n",
      "     |  \n",
      "     |  tm_year\n",
      "     |      year, for example, 1993\n",
      "     |  \n",
      "     |  tm_zone\n",
      "     |      abbreviation of timezone name\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  n_fields = 11\n",
      "     |  \n",
      "     |  n_sequence_fields = 9\n",
      "     |  \n",
      "     |  n_unnamed_fields = 0\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from builtins.tuple:\n",
      "     |  \n",
      "     |  __add__(self, value, /)\n",
      "     |      Return self+value.\n",
      "     |  \n",
      "     |  __contains__(self, key, /)\n",
      "     |      Return key in self.\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __getitem__(self, key, /)\n",
      "     |      Return self[key].\n",
      "     |  \n",
      "     |  __getnewargs__(self, /)\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __iter__(self, /)\n",
      "     |      Implement iter(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __len__(self, /)\n",
      "     |      Return len(self).\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __mul__(self, value, /)\n",
      "     |      Return self*value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __rmul__(self, value, /)\n",
      "     |      Return value*self.\n",
      "     |  \n",
      "     |  count(self, value, /)\n",
      "     |      Return number of occurrences of value.\n",
      "     |  \n",
      "     |  index(self, value, start=0, stop=9223372036854775807, /)\n",
      "     |      Return first index of value.\n",
      "     |      \n",
      "     |      Raises ValueError if the value is not present.\n",
      "\n",
      "FUNCTIONS\n",
      "    asctime(...)\n",
      "        asctime([tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\n",
      "        When the time tuple is not present, current time as returned by localtime()\n",
      "        is used.\n",
      "    \n",
      "    ctime(...)\n",
      "        ctime(seconds) -> string\n",
      "        \n",
      "        Convert a time in seconds since the Epoch to a string in local time.\n",
      "        This is equivalent to asctime(localtime(seconds)). When the time tuple is\n",
      "        not present, current time as returned by localtime() is used.\n",
      "    \n",
      "    get_clock_info(...)\n",
      "        get_clock_info(name: str) -> dict\n",
      "        \n",
      "        Get information of the specified clock.\n",
      "    \n",
      "    gmtime(...)\n",
      "        gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n",
      "                               tm_sec, tm_wday, tm_yday, tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n",
      "        GMT).  When 'seconds' is not passed in, convert the current time instead.\n",
      "        \n",
      "        If the platform supports the tm_gmtoff and tm_zone, they are available as\n",
      "        attributes only.\n",
      "    \n",
      "    localtime(...)\n",
      "        localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,\n",
      "                                  tm_sec,tm_wday,tm_yday,tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing local time.\n",
      "        When 'seconds' is not passed in, convert the current time instead.\n",
      "    \n",
      "    mktime(...)\n",
      "        mktime(tuple) -> floating point number\n",
      "        \n",
      "        Convert a time tuple in local time to seconds since the Epoch.\n",
      "        Note that mktime(gmtime(0)) will not generally return zero for most\n",
      "        time zones; instead the returned value will either be equal to that\n",
      "        of the timezone or altzone attributes on the time module.\n",
      "    \n",
      "    monotonic(...)\n",
      "        monotonic() -> float\n",
      "        \n",
      "        Monotonic clock, cannot go backward.\n",
      "    \n",
      "    monotonic_ns(...)\n",
      "        monotonic_ns() -> int\n",
      "        \n",
      "        Monotonic clock, cannot go backward, as nanoseconds.\n",
      "    \n",
      "    perf_counter(...)\n",
      "        perf_counter() -> float\n",
      "        \n",
      "        Performance counter for benchmarking.\n",
      "    \n",
      "    perf_counter_ns(...)\n",
      "        perf_counter_ns() -> int\n",
      "        \n",
      "        Performance counter for benchmarking as nanoseconds.\n",
      "    \n",
      "    process_time(...)\n",
      "        process_time() -> float\n",
      "        \n",
      "        Process time for profiling: sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    process_time_ns(...)\n",
      "        process_time() -> int\n",
      "        \n",
      "        Process time for profiling as nanoseconds:\n",
      "        sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    sleep(...)\n",
      "        sleep(seconds)\n",
      "        \n",
      "        Delay execution for a given number of seconds.  The argument may be\n",
      "        a floating point number for subsecond precision.\n",
      "    \n",
      "    strftime(...)\n",
      "        strftime(format[, tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string according to a format specification.\n",
      "        See the library reference manual for formatting codes. When the time tuple\n",
      "        is not present, current time as returned by localtime() is used.\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    strptime(...)\n",
      "        strptime(string, format) -> struct_time\n",
      "        \n",
      "        Parse a string to a time tuple according to a format specification.\n",
      "        See the library reference manual for formatting codes (same as\n",
      "        strftime()).\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    time(...)\n",
      "        time() -> floating point number\n",
      "        \n",
      "        Return the current time in seconds since the Epoch.\n",
      "        Fractions of a second may be present if the system clock provides them.\n",
      "    \n",
      "    time_ns(...)\n",
      "        time_ns() -> int\n",
      "        \n",
      "        Return the current time in nanoseconds since the Epoch.\n",
      "    \n",
      "    tzset(...)\n",
      "        tzset()\n",
      "        \n",
      "        Initialize, or reinitialize, the local timezone to the value stored in\n",
      "        os.environ['TZ']. The TZ environment variable should be specified in\n",
      "        standard Unix timezone format as documented in the tzset man page\n",
      "        (eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently\n",
      "        fall back to UTC. If the TZ environment variable is not set, the local\n",
      "        timezone is set to the systems best guess of wallclock time.\n",
      "        Changing the TZ environment variable without calling tzset *may* change\n",
      "        the local timezone used by methods such as localtime, but this behaviour\n",
      "        should not be relied on.\n",
      "\n",
      "DATA\n",
      "    altzone = -28800\n",
      "    daylight = 0\n",
      "    timezone = -28800\n",
      "    tzname = ('CST', 'CST')\n",
      "\n",
      "FILE\n",
      "    (built-in)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "224e4b7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=9, tm_mday=9, tm_hour=22, tm_min=16, tm_sec=37, tm_wday=3, tm_yday=252, tm_isdst=0)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e011f041",
   "metadata": {},
   "source": [
    "##转换成UTC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "3667c08c",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function gmtime in module time:\n",
      "\n",
      "gmtime(...)\n",
      "    gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n",
      "                           tm_sec, tm_wday, tm_yday, tm_isdst)\n",
      "    \n",
      "    Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n",
      "    GMT).  When 'seconds' is not passed in, convert the current time instead.\n",
      "    \n",
      "    If the platform supports the tm_gmtoff and tm_zone, they are available as\n",
      "    attributes only.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time.gmtime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "0b02f3d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=9, tm_mday=9, tm_hour=14, tm_min=18, tm_sec=51, tm_wday=3, tm_yday=252, tm_isdst=0)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e355bfed",
   "metadata": {},
   "source": [
    "##如何知道标准库的某个特定标准做什么\n",
    "####查看python文档官方的标准库答案：https://docs.python.org/3/library/index.html"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff2e4fb4",
   "metadata": {},
   "source": [
    "## 2.认识变量、赋值、数据\n",
    "##变量名的第一个字符不能是数字 以下关键字不能声明为变量名 ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda','not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "664f0748",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = \"Sitong\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "b4394e75",
   "metadata": {},
   "outputs": [],
   "source": [
    "name2 = name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "7dd99953",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Qianya Sitong\n"
     ]
    }
   ],
   "source": [
    "print(name,name2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "dbc8e2b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = 'Qianya'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "0565f414",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "What is the value of name2 now?\n"
     ]
    }
   ],
   "source": [
    "print(\"What is the value of name2 now?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "707ec5fe",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "86903533",
   "metadata": {},
   "outputs": [],
   "source": [
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "afc68720",
   "metadata": {},
   "outputs": [],
   "source": [
    "right_this_minute = datetime.today().minute"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b1e8e0ca",
   "metadata": {},
   "source": [
    "# # 3.循环嵌套 练习if elif\n",
    "if  :\n",
    "    #  为 True 时执行此处代码块\n",
    "else :\n",
    "    # 为 False 时则执行此处代码块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c34306cf",
   "metadata": {},
   "source": [
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f28d24cd",
   "metadata": {},
   "source": [
    "# # 4.for 循环 内置函数range（）\n",
    "for ：代码块要重复执行的次数已知：带计数的循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "5de8e3ec",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    " for i in [1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "4c7fba7c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H\n",
      "i\n",
      "!\n"
     ]
    }
   ],
   "source": [
    "for ch in \"Hi!\":\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "4805c787",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Head First Rocks!\n",
      "Head First Rocks!\n",
      "Head First Rocks!\n",
      "Head First Rocks!\n",
      "Head First Rocks!\n"
     ]
    }
   ],
   "source": [
    "for num in range(5):\n",
    "    print('Head First Rocks!')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "af3dd277",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[99,\n",
       " 98,\n",
       " 97,\n",
       " 96,\n",
       " 95,\n",
       " 94,\n",
       " 93,\n",
       " 92,\n",
       " 91,\n",
       " 90,\n",
       " 89,\n",
       " 88,\n",
       " 87,\n",
       " 86,\n",
       " 85,\n",
       " 84,\n",
       " 83,\n",
       " 82,\n",
       " 81,\n",
       " 80,\n",
       " 79,\n",
       " 78,\n",
       " 77,\n",
       " 76,\n",
       " 75,\n",
       " 74,\n",
       " 73,\n",
       " 72,\n",
       " 71,\n",
       " 70,\n",
       " 69,\n",
       " 68,\n",
       " 67,\n",
       " 66,\n",
       " 65,\n",
       " 64,\n",
       " 63,\n",
       " 62,\n",
       " 61,\n",
       " 60,\n",
       " 59,\n",
       " 58,\n",
       " 57,\n",
       " 56,\n",
       " 55,\n",
       " 54,\n",
       " 53,\n",
       " 52,\n",
       " 51,\n",
       " 50,\n",
       " 49,\n",
       " 48,\n",
       " 47,\n",
       " 46,\n",
       " 45,\n",
       " 44,\n",
       " 43,\n",
       " 42,\n",
       " 41,\n",
       " 40,\n",
       " 39,\n",
       " 38,\n",
       " 37,\n",
       " 36,\n",
       " 35,\n",
       " 34,\n",
       " 33,\n",
       " 32,\n",
       " 31,\n",
       " 30,\n",
       " 29,\n",
       " 28,\n",
       " 27,\n",
       " 26,\n",
       " 25,\n",
       " 24,\n",
       " 23,\n",
       " 22,\n",
       " 21,\n",
       " 20,\n",
       " 19,\n",
       " 18,\n",
       " 17,\n",
       " 16,\n",
       " 15,\n",
       " 14,\n",
       " 13,\n",
       " 12,\n",
       " 11,\n",
       " 10,\n",
       " 9,\n",
       " 8,\n",
       " 7,\n",
       " 6,\n",
       " 5,\n",
       " 4,\n",
       " 3,\n",
       " 2,\n",
       " 1]"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(5)\n",
    "\n",
    "list(range(5))\n",
    "\n",
    "list(range(5,10))\n",
    "\n",
    "list(range(0,10,2))\n",
    "\n",
    "list(range(10,0,-2))\n",
    "\n",
    "list(range(10,0,2))\n",
    "\n",
    "list(range(99,0,-1))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dcc1fc0b",
   "metadata": {},
   "source": [
    "# # 5.random模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "d7f15423",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.894611634246908\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "print(random.random())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "986470dd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n"
     ]
    }
   ],
   "source": [
    " print (random.randint(1,7))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "531af074",
   "metadata": {},
   "source": [
    "# ##课后章节练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "5134fded",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.8.8 (default, Apr 13 2021, 12:59:45) \n",
      "[Clang 10.0.0 ]\n"
     ]
    }
   ],
   "source": [
    "print(sys.version)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "c2f1d72a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "environ{'TERM_SESSION_ID': 'C7BE23D3-8F1E-4B80-9442-22C040EB1473',\n",
       "        'CONDA_ROOT': '/opt/anaconda3',\n",
       "        'TMPDIR': '/var/folders/mr/gshzl4sn75l_l0fb_9_zfpf80000gn/T/',\n",
       "        'XPC_FLAGS': '0x0',\n",
       "        'TERM': 'xterm-color',\n",
       "        'LANG': 'zh_CN.UTF-8',\n",
       "        'SSH_AUTH_SOCK': '/private/tmp/com.apple.launchd.RloJ5YAIm6/Listeners',\n",
       "        'XPC_SERVICE_NAME': '0',\n",
       "        'TERM_PROGRAM': 'Apple_Terminal',\n",
       "        'TERM_PROGRAM_VERSION': '433',\n",
       "        'QT_API': 'pyqt5',\n",
       "        'SHLVL': '2',\n",
       "        'PWD': '/Users/wenqy1022',\n",
       "        'SHELL': '/bin/zsh',\n",
       "        'HOME': '/Users/wenqy1022',\n",
       "        'LOGNAME': 'wenqy1022',\n",
       "        'USER': 'wenqy1022',\n",
       "        'PATH': '/opt/anaconda3/bin:/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',\n",
       "        'OLDPWD': '/Users/wenqy1022',\n",
       "        'CONDA_EXE': '/opt/anaconda3/bin/conda',\n",
       "        '_CE_M': '',\n",
       "        '_CE_CONDA': '',\n",
       "        'CONDA_PYTHON_EXE': '/opt/anaconda3/bin/python',\n",
       "        'CONDA_SHLVL': '1',\n",
       "        'CONDA_PREFIX': '/opt/anaconda3',\n",
       "        'CONDA_DEFAULT_ENV': 'base',\n",
       "        'CONDA_PROMPT_MODIFIER': '(base) ',\n",
       "        'LC_CTYPE': 'UTF-8',\n",
       "        '_': '/opt/anaconda3/bin/jupyter',\n",
       "        'JPY_PARENT_PID': '2654',\n",
       "        'CLICOLOR': '1',\n",
       "        'PAGER': 'cat',\n",
       "        'GIT_PAGER': 'cat',\n",
       "        'MPLBACKEND': 'module://ipykernel.pylab.backend_inline'}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.environ"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e6c97e7a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "environ{'TERM_SESSION_ID': 'C7BE23D3-8F1E-4B80-9442-22C040EB1473',\n",
       "        'CONDA_ROOT': '/opt/anaconda3',\n",
       "        'TMPDIR': '/var/folders/mr/gshzl4sn75l_l0fb_9_zfpf80000gn/T/',\n",
       "        'XPC_FLAGS': '0x0',\n",
       "        'TERM': 'xterm-color',\n",
       "        'LANG': 'zh_CN.UTF-8',\n",
       "        'SSH_AUTH_SOCK': '/private/tmp/com.apple.launchd.RloJ5YAIm6/Listeners',\n",
       "        'XPC_SERVICE_NAME': '0',\n",
       "        'TERM_PROGRAM': 'Apple_Terminal',\n",
       "        'TERM_PROGRAM_VERSION': '433',\n",
       "        'QT_API': 'pyqt5',\n",
       "        'SHLVL': '2',\n",
       "        'PWD': '/Users/wenqy1022',\n",
       "        'SHELL': '/bin/zsh',\n",
       "        'HOME': '/Users/wenqy1022',\n",
       "        'LOGNAME': 'wenqy1022',\n",
       "        'USER': 'wenqy1022',\n",
       "        'PATH': '/opt/anaconda3/bin:/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',\n",
       "        'OLDPWD': '/Users/wenqy1022',\n",
       "        'CONDA_EXE': '/opt/anaconda3/bin/conda',\n",
       "        '_CE_M': '',\n",
       "        '_CE_CONDA': '',\n",
       "        'CONDA_PYTHON_EXE': '/opt/anaconda3/bin/python',\n",
       "        'CONDA_SHLVL': '1',\n",
       "        'CONDA_PREFIX': '/opt/anaconda3',\n",
       "        'CONDA_DEFAULT_ENV': 'base',\n",
       "        'CONDA_PROMPT_MODIFIER': '(base) ',\n",
       "        'LC_CTYPE': 'UTF-8',\n",
       "        '_': '/opt/anaconda3/bin/jupyter',\n",
       "        'JPY_PARENT_PID': '2654',\n",
       "        'CLICOLOR': '1',\n",
       "        'PAGER': 'cat',\n",
       "        'GIT_PAGER': 'cat',\n",
       "        'MPLBACKEND': 'module://ipykernel.pylab.backend_inline'}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.environ"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "c0e846f7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2021, 10, 10)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime\n",
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "042d5a8c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
